

package com.realphim.app.util;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
/**
 * class provide some common utilities for all app
 * @author MinhTDH
 *
 *********************************************************
 */
public class CommonUtil {
	/**
	 * hide software input
	 * @param context
	 * Return void
	 * @author MinhTDH
	 *********************************************************
	 */
	public static void hideSoftWareInput(Activity context) {
		InputMethodManager inputManager = (InputMethodManager) context.
				getSystemService(Context.INPUT_METHOD_SERVICE); 
		if (context.getCurrentFocus() != null) {
			inputManager.hideSoftInputFromWindow(context.getCurrentFocus().getWindowToken(),0);
		}
	}
	/**
	 * show software input and focus in View v
	 * @param context
	 * @param v
	 * Return void
	 * @author MinhTDH
	 *********************************************************
	 */
	public static void showSoftWareInput(Context context, View v) {
		
		InputMethodManager inputManager = (InputMethodManager) context.
				getSystemService(Context.INPUT_METHOD_SERVICE);
		//inputManager.showSoftInput(v, 0);
		inputManager.toggleSoftInput(0, 0); //vuongtm
	}
	
    // public static boolean checkExternalStorageAvailable() {
    // // String state = Environment.getExternalStorageState();
    // // System.out.println("check SD card");
    // // System.out.println("envi path " +
    // Environment.getExternalStorageDirectory().getPath());
    // // System.out.println("mount state" +
    // Environment.MEDIA_MOUNTED.equalsIgnoreCase(state));
    // boolean ret = false;
    // File f = new File(BookShelfDatabaseManager.getDatabasePath());
    // ret = f.exists();
    // return ret;//Environment.MEDIA_MOUNTED.equalsIgnoreCase(state);
    // }
}
